var yesBtn = document.getElementById('yesBtn');
var backBtn = document.getElementById('backBtn');

yesBtn.addEventListener('click', function() {
  var beforPwd = document.getElementById('forPwd').value;
  var newPwd = document.getElementById('newPwd').value;
  var twicePwd = document.getElementById('twicePwd').value;

  console.log(beforPwd);
  console.log(newPwd);
  console.log(twicePwd);
  // 这里可以编写后端调用的代码，验证用户名和密码是否匹配数据库
  var confirmLogout = confirm("确定要修改吗？");
  if (confirmLogout) {

  $.ajax({
    url: '/management/changeservlet/stuChangePwd',
    method: 'POST',
    data: {
      oldPwd: beforPwd,
      newPwd: newPwd,
      twicePwd: twicePwd
    },
    success: function(response) {
      // 处理响应数据
      if (response.flag) {
              // 成功
              console.log(response.errorMsg);
              alert(response.errorMsg);
              console.log("way1");
            } else {
              // 失败
              console.log(response.errorMsg);
              alert(response.errorMsg);
              console.log("way2");
              window.location.href = "stulogin_menu.html";
            }
    },
    error: function(xhr, status, error) {
      // 处理错误
      console.log(error);
      console.log("way3");
    }
  });
  }else {
      // 用户点击了取消按钮
      // 可以选择执行其他操作或不进行任何操作
      console.log("way4");
  }
});

backBtn.addEventListener('click', function() {
  // 返回上一个页面的操作
  window.history.back();
});

var content = document.querySelector('.content');

content.addEventListener('mouseenter', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.5)'; // 将透明度更改为 0.5，使背景色加深
});

content.addEventListener('mouseleave', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.2)'; // 将透明度恢复为 0.2，使背景色变浅
});